home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_qt.idb / usr / freeware / include / Qt / qfont.h.z / qfont.h
Encoding:
C/C++ Source or Header  |  1998-10-28  |  4.4 KB  |  161 lines

  1. /****************************************************************************
  2. ** $Id: qfont.h,v 2.11 1998/07/03 00:09:33 hanord Exp $
  3. **
  4. ** Definition of QFont class
  5. **
  6. ** Created : 940514
  7. **
  8. ** Copyright (C) 1992-1998 Troll Tech AS.  All rights reserved.
  9. **
  10. ** This file is part of Qt Free Edition, version 1.40.
  11. **
  12. ** See the file LICENSE included in the distribution for the usage
  13. ** and distribution terms, or http://www.troll.no/free-license.html.
  14. **
  15. ** IMPORTANT NOTE: You may NOT copy this file or any part of it into
  16. ** your own programs or libraries.
  17. **
  18. ** Please see http://www.troll.no/pricing.html for information about 
  19. ** Qt Professional Edition, which is this same library but with a
  20. ** license which allows creation of commercial/proprietary software.
  21. **
  22. *****************************************************************************/
  23.  
  24. #ifndef QFONT_H
  25. #define QFONT_H
  26.  
  27. #ifndef QT_H
  28. #include "qwindowdefs.h"
  29. #include "qstring.h"
  30. #endif // QT_H
  31.  
  32.  
  33. class  QStrList;
  34. struct QFontDef;
  35. struct QFontData;
  36. class  QFontInternal;
  37.  
  38.  
  39. class QFont                    // font class
  40. {
  41. public:
  42.     enum StyleHint { Helvetica, Times, Courier, OldEnglish,  System, AnyStyle,
  43.              SansSerif    = Helvetica,
  44.              Serif    = Times,
  45.              TypeWriter = Courier,
  46.              Decorative = OldEnglish};
  47.     enum Weight       { Light = 25, Normal = 50, DemiBold = 63,
  48.              Bold  = 75, Black    = 87 };
  49.     enum CharSet   { Latin1, ISO_8859_1 = Latin1, AnyCharSet,
  50.              Latin2, ISO_8859_2 = Latin2,
  51.              Latin3, ISO_8859_3 = Latin3,
  52.              Latin4, ISO_8859_4 = Latin4,
  53.              Latin5, ISO_8859_5 = Latin5,
  54.              Latin6, ISO_8859_6 = Latin6,
  55.              Latin7, ISO_8859_7 = Latin7,
  56.              Latin8, ISO_8859_8 = Latin8,
  57.              Latin9, ISO_8859_9 = Latin9,
  58.              KOI8R };
  59.  
  60.     QFont();                    // default font
  61.     QFont( const char *family, int pointSize = 12,
  62.        int weight = Normal, bool italic = FALSE );
  63.     QFont( const char *family, int pointSize,
  64.        int weight, bool italic, CharSet charSet );
  65.     QFont( const QFont & );
  66.     virtual ~QFont();
  67.     QFont      &operator=( const QFont & );
  68.  
  69.     const char *family()    const;
  70.     void    setFamily( const char * );
  71.     int        pointSize()    const;
  72.     void    setPointSize( int );
  73.     int        weight()    const;
  74.     void    setWeight( int );
  75.     bool    bold()        const;
  76.     void    setBold( bool );
  77.     bool    italic()    const;
  78.     void    setItalic( bool );
  79.     bool    underline()    const;
  80.     void    setUnderline( bool );
  81.     bool    strikeOut()    const;
  82.     void    setStrikeOut( bool );
  83.     bool    fixedPitch()    const;
  84.     void    setFixedPitch( bool );
  85.     StyleHint    styleHint()    const;
  86.     void    setStyleHint( StyleHint );
  87.     CharSet    charSet()    const;
  88.     void    setCharSet( CharSet );
  89.     bool    rawMode()    const;
  90.     void    setRawMode( bool );
  91.  
  92.     bool    exactMatch()    const;
  93.  
  94.     bool    operator==( const QFont & ) const;
  95.     bool    operator!=( const QFont & ) const;
  96.     bool    isCopyOf( const QFont & ) const;
  97.  
  98.     HANDLE    handle( HANDLE=0 ) const;
  99.  
  100.     QString    key() const;
  101.  
  102.     static const QFont &defaultFont();
  103.     static void setDefaultFont( const QFont & );
  104.  
  105.     static const char  *substitute( const char *familyName );
  106.     static void insertSubstitution( const char *, const char * );
  107.     static void removeSubstitution( const char * );
  108.     static void listSubstitutions( QStrList * );
  109.  
  110.     static void initialize();
  111.     static void cleanup();
  112.     static void cacheStatistics();
  113.  
  114. protected:
  115.     bool    dirty()            const;
  116.  
  117.     QString    defaultFamily()        const;
  118.     QString    lastResortFamily()    const;
  119.     QString    lastResortFont()    const;
  120.     int        deciPointSize()        const;
  121.  
  122. private:
  123.     QFont( QFontData * );
  124.     QFont( bool );
  125.     void    init();
  126.     void    detach();
  127.     void    initFontInfo()        const;
  128.     void    load( HANDLE=0 )    const;
  129. #if defined(_WS_WIN_)
  130.     HANDLE    create( bool *, HANDLE=0 ) const;
  131.     void       *textMetric()        const;
  132. #endif
  133.  
  134.     friend class QFontMetrics;
  135.     friend class QFontInfo;
  136.     friend class QPainter;
  137.     friend QDataStream &operator<<( QDataStream &, const QFont & );
  138.     friend QDataStream &operator>>( QDataStream &, QFont & );
  139.  
  140.     QFontData     *d;                // internal font data
  141.     static QFont *defFont;
  142. };
  143.  
  144.  
  145. inline bool QFont::bold() const
  146. { return weight() > Normal; }
  147.  
  148. inline void QFont::setBold( bool enable )
  149. { setWeight( enable ? Bold : Normal ); }
  150.  
  151.  
  152. /*****************************************************************************
  153.   QFont stream functions
  154.  *****************************************************************************/
  155.  
  156. QDataStream &operator<<( QDataStream &, const QFont & );
  157. QDataStream &operator>>( QDataStream &, QFont & );
  158.  
  159.  
  160. #endif // QFONT_H
  161.